﻿using Shop.RemoteModel.PageModule.Model;
using Shop.RemoteModel.PageModule.ModuleConfig;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/page/template/module/{name}")]
    internal class PageModuleApi : ApiController
    {
        private readonly IPageModuleService _Service;

        public PageModuleApi ( IPageModuleService service )
        {
            this._Service = service;
        }

        public long Add ( PageModuleAdd data )
        {
            return this._Service.Add(data);
        }

        public void Delete ( [NumValidate("shop.page.template.module.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }

        public PageModuleDto Get ( [NumValidate("shop.page.template.module.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public PageModuleBase[] Gets ( [NumValidate("shop.page.template.id.error", 1)] long templateId )
        {
            return this._Service.Gets(templateId);
        }

        public bool Set ( LongParam<PageModuleSet> param )
        {
            return this._Service.Set(param.Id, param.Value);
        }

        public void SetSort ( [NullValidate("public.param.null")] ModuleSortSet[] sorts )
        {
            this._Service.SetSort(sorts);
        }
    }
}
